<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title><spring:message code="create_fashion_style"/></title>
    <%@ include file="/WEB-INF/views/include/head.jsp"%>
    <script src="${ctxStatic}/js/jquery-1.9.1.min.js"></script>
	<link rel="stylesheet" href="${ctxStatic}/css/layerSm.css">
	<link rel="stylesheet" href="${ctxStatic}/css/common_erp.css">
	<script src="${ctxStatic}/layDate/laydate.js"></script>
	<script type="text/javascript">
		$(document).ready(function() {
			// 下拉选框带搜索功能
			$("#opinionName").select2();
			if ("${bigcargoStyle.uploadFlg=='fashionStyleCreate'||bigcargoStyle.uploadFlg=='specimenDemandCreate'}") {
				$("#opinionName").attr("disabled",true);
			}
		});

		// 添加按钮
		function addList() {
			 $("#inputForm").validate({
           	  submitHandler : function() {
           		   // 意见选择check
                 if ($("#opinionName >option:selected").val() != '') {
                	//获取 iframe 数量 
               		var frLength = window.parent.frames.length;
               		//父画面下标 
               		var parentIndex = frLength-2;
                	var tbodyTemp = window.parent.frames[parentIndex].document.getElementById("addOpinionBody");
                	var len = $(tbodyTemp).find("tr").length;
             		var opinionName = $(".select2-chosen")[0].innerText;
             		var opinionNameHidden = "<input type='hidden' name='styleFeedBack.styleFeedBackList[tempIndex].phaseCd' value='"+$("#opinionName >option:selected").val()+"'/>";
             		var remarks = $("#remarks").val();
             		var remarksHidden = "<input type='hidden' name='styleFeedBack.styleFeedBackList[tempIndex].feedRemarks' value='"+remarks+"'/>";
             		var createPeople = $("#createPeople").val();
             		var createPeopleHidden = "<input type='hidden' name='styleFeedBack.styleFeedBackList[tempIndex].createUser' value='"+ $("#createUser").val()+"'/>";
             		var createDate = $("#createDate").val();
             		var createDateHidden = "<input type='hidden' name='styleFeedBack.styleFeedBackList[tempIndex].createTime' value='"+createDate+"'/>";
             		var fileName = $("#uploadIpiton").val();
                     var filePathHidden = "";
                     var fileNameHidden = "";
                     var fileKbnHidden = "";
                     var ftpFileHidden = "";
                     var modelFileHidden = "";
                     var fileHtml = "";
                     var count = 0;

                    if (fileName != "") {
                        var fileItem = fileName.split("|/");
                        var fileIndex = 0;
                        for (var i = 1; i<fileItem.length; i++) {
                            var fileTemp = fileItem[i].split("/");
                            var urlTemp = '';
                            var lenTemp = fileTemp.length-1;
                            var nameTemp=$("#uploadIpitonPreview").find("li a").eq(count).text();
                            fileHtml += "<a href='/"+fileItem[i]+"' url='/"+fileItem[i]+"' target='_blank'>"+nameTemp+"</a><br>";
                            if (fileItem[i]!='') {
                                for (var j = 0; j<lenTemp;j++) {
                                    urlTemp += fileTemp[j]+"/";
                                }
                                filePathHidden += '<input type ="hidden" name="styleFeedBack.styleFeedBackList[tempIndex].uploadFileData.uploadStyleList['+fileIndex+'].uploadFileName" value = "'+nameTemp+'"/>';
                                fileNameHidden += '<input type ="hidden" name="styleFeedBack.styleFeedBackList[tempIndex].uploadFileData.uploadStyleList['+fileIndex+'].filePath" value = "/'+urlTemp+'"/>';
                                fileKbnHidden += '<input type ="hidden" name="styleFeedBack.styleFeedBackList[tempIndex].uploadFileData.uploadStyleList['+fileIndex+'].fileKbn" value = "1"/>';
                                ftpFileHidden += '<input type ="hidden" name="styleFeedBack.styleFeedBackList[tempIndex].uploadFileData.uploadStyleList['+fileIndex+'].ftpFile" value = "/optionFile" />';
                                modelFileHidden += '<input type ="hidden" name="styleFeedBack.styleFeedBackList[tempIndex].uploadFileData.uploadStyleList['+fileIndex+'].moduleKbn" value = "2" />';
                            }
                            count = count+2;
                            fileIndex = fileIndex + 1;
                        }
                    }
             		var hiddenData = opinionNameHidden+createPeopleHidden+createDateHidden+remarksHidden+filePathHidden+fileNameHidden+ftpFileHidden+fileKbnHidden+modelFileHidden;
             		var tempData = $(tbodyTemp).find("tr").eq(0).clone();
             		var tempDataCells=$(tempData)[0].cells;
             		tempDataCells[1].innerText=opinionName;
             		tempDataCells[2].innerHTML = fileHtml;
             		tempDataCells[3].innerText=remarks;
             		tempDataCells[4].innerText=createPeople;
             		tempDataCells[5].innerText=createDate;
             		tempDataCells[6].innerHTML=hiddenData;
             		$(tempData)[0].className="";
             		$(tempData).find("div").innerHTML = hiddenData;
             		tempData.appendTo(tbodyTemp);
             		closeWin();
                 }
           	 },
           });
			 $("#inputForm").submit();
		}
    </script>
</head>
<body>
<form id="inputForm" method="post">
<c:if test="${bigcargoStyle.uploadFlg=='fashionStyleCreate'}">
<c:set value="<%=ResourcesUtil.getConfig(\"OPINION-initialOpinion\") %>" var="opinion"/>
</c:if>
<c:if test="${bigcargoStyle.uploadFlg=='specimenDemandCreate'}">
<c:set value="<%=ResourcesUtil.getConfig(\"OPINION-styleOpinion\") %>" var="opinion"/>
</c:if>
<div class="tabBoxSm">
     <div class="tabSm smOrderBox" style="width:800px">
        <div class="items clearfix">
            <div class="col-50 clearfix">
                <strong style="font-size:15px;"><spring:message code="opinion_request"/></strong>
            </div>
            <div class="col-50 clearfix" >
            <div style="float:right;">
               <!-- 添加 -->
               <button type="button" class="btn-cj" onclick="addList()"><spring:message code="company_account_create"/></button>
               <!-- 关闭 -->
               <button type="button" class="btn-js" onclick="closeWin()"><spring:message code="btn_cancle"/></button>
               </div>
            </div>
            <br><hr></hr>
        </div>
        <div class="items clearfix">
            <div class="col-16 clearfix">
			 <p class="tit_muster"><spring:message code="opinion_moment"/></p>
			  <select style="width:130px" id="opinionName" name="opinionName" data-rule-required="true" data-msg-required="<spring:message code="style_selectOpinion"/>">
			   <option value=""><spring:message
									code="order_please_choose" /></option>
			<c:forEach items="${opinionList}" var="item">
				<option value="${item.itemCode}-${item.itemValue}" <c:if test="${fn:split(opinion,'-')[1] eq item.itemValue}">selected="selected"</c:if>>${item.itemName}</option>
			</c:forEach>
			</select>
            </div>
            <div class="col-16 clearfix">
                <p class="tit_muster"><spring:message code="cteate_people"/></p>
			<input type="text" id ="createPeople" name ="createPeople" style="width:120px;" value="${user.firstName}${user.lastName}" readonly="readonly">
			<input type="hidden" id ="createUser"  value="${fns:getUser()}">
            </div>
            <div class="col-16 clearfix">
                <p class="tit_muster"><spring:message code="cteate_date"/></p>
                 <input type="text" id="createDate" name="createDate" style="width: 130px" value="${fns:getDate('yyyy-MM-dd HH:mm')}" readonly="readonly">
            </div>
        </div>
		<div class="items clearfix" style="margin: 0px;">
            <div class="col-16 clearfix">
                <strong style="font-size:12px;"><spring:message code="opinion_require_content"/></strong>
                <img src="${ctxStatic}/images/fujian.png" class="delBtn" style="width:25px" onclick="uploadIpitonFinderOpen()">

            </div>
            <div class="col-16 clearfix" style = "width: 400px">
                <div style="position:absolute;height:30px;width:300px; overflow-y: auto">
                <input style="width:70%" id="uploadIpiton" type="hidden" name="filePath"  value=""  htmlEscape="false" maxlength="255" class="input-xlarge" data-rule-required="true" data-msg-required="<spring:message code="file_selectOpinion"/>" />
                <sys:ckfinder input="uploadIpiton" type="files" uploadPath="/optionFile" selectMultiple="true"  readonly = "true"/>
                </div>
            </div>
        </div>
        <textarea name="remarks" id ="remarks"  class="text_sketch" style="width: 760px; height: 290px;"></textarea>
     </div>
</div>
</form>
</body>
</html>
